Skip to content

Conversation

@VictoriousRaptor
Copy link
Contributor

@VictoriousRaptor VictoriousRaptor commented Nov 18, 2023

This pull request introduces a comprehensive set of changes to enhance Pinyin support in the application, including the addition of Double Pinyin (“双拼”) functionality, improved translation mappings, and related settings. The most significant updates include the implementation of the IAlphabet interface, the refactoring of the PinyinAlphabet class, the introduction of Double Pinyin schemas, and updates to the user settings and localization files.

UI in General Panel

Clip_20250713_194052

Pinyin and Double Pinyin Enhancements:

  • Added the IAlphabet interface to define methods for language translation and determining translatability. (Flow.Launcher.Infrastructure/IAlphabet.cs)
  • Refactored the PinyinAlphabet class to support Double Pinyin, utilize a cache for translations, and dynamically reload schemas based on user settings. (Flow.Launcher.Infrastructure/PinyinAlphabet.cs)
  • Introduced Double Pinyin schemas as an enum and added settings for enabling/disabling Double Pinyin and selecting schemas. (Flow.Launcher.Infrastructure/UserSettings/Settings.cs) [1] [2]

Translation Mapping Improvements:

  • Reimplemented the TranslationMapping class to simplify and optimize the mapping of original to translated indices. (Flow.Launcher.Infrastructure/TranslationMapping.cs)
  • Added unit tests for TranslationMapping to validate its functionality. (Flow.Launcher.Test/TranslationMappingTest.cs)

Localization and Resource Updates:

  • Updated localization files to include strings for Double Pinyin settings and schemas. (Flow.Launcher/Languages/en.xaml)
  • Added double_pinyin.json to project resources for schema definitions. (Flow.Launcher/Flow.Launcher.csproj)

Codebase Simplifications:

  • Updated methods in StringMatcher.cs to use the new ShouldTranslate method from IAlphabet. (Flow.Launcher.Infrastructure/StringMatcher.cs)
  • Made helper methods IsAcronym and IsAcronymCount static for better encapsulation. (Flow.Launcher.Infrastructure/StringMatcher.cs) [1] [2]

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@VictoriousRaptor VictoriousRaptor marked this pull request as draft November 19, 2023 03:48
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@taooceros
Copy link
Member

@VictoriousRaptor what's the status of this pr?

@VictoriousRaptor
Copy link
Contributor Author

@VictoriousRaptor what's the status of this pr?

POC. I'm using it daily and so far so good. Since there're many double pinyin mappings we should make it user configurable. Is it acceptable to allow users to edit a json file that defines the mapping?

@taooceros
Copy link
Member

well I can't think anything better...maybe I do want this to be plugin-able, but can't think of a good way to design the api.

@github-actions

This comment has been minimized.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for Double Pinyin in search by exposing new toggles in the UI, loading a JSON-based mapping table, and wiring it through settings, view models, and the PinyinAlphabet.

  • UI: new switch and combo box for enabling double-pinyin and selecting a schema
  • Settings & ViewModel: new UseDoublePinyin and DoublePinyinSchema properties, with binding and localization
  • Core logic: JSON file of mappings, loading in PinyinAlphabet, and a new TranslationMapping class with unit tests

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
SettingPages/Views/SettingsPaneGeneral.xaml Added cards/toggles and schema selector
SettingsPaneGeneralViewModel.cs Introduced UseDoublePinyin, schema list
Resources/double_pinyin.json New mapping table for all supported schemas
Languages/en.xaml Added localization for toggles and schemas
Flow.Launcher.csproj Ensured JSON is copied to output
TranslationMapping.cs New mapping utility with AddNewIndex/MapToOriginalIndex
TranslationMappingTest.cs Unit tests for TranslationMapping
UserSettings/Settings.cs Added settings, JSON serialization, enum
Infrastructure/StringMatcher.cs Switched to ShouldTranslate predicate
Infrastructure/PinyinAlphabet.cs Loads JSON, applies double-pinyin translation
Infrastructure/IAlphabet.cs Updated interface to use ShouldTranslate
Comments suppressed due to low confidence (3)

Flow.Launcher.Infrastructure/TranslationMapping.cs:29

  • Method name 'endConstruct' doesn't follow .NET naming conventions; consider renaming to 'EndConstruct'.
        public void endConstruct()

Flow.Launcher.Infrastructure/TranslationMapping.cs:29

  • The behavior of endConstruct isn't covered by unit tests; consider adding tests to verify it prevents further calls to AddNewIndex after construction.
        public void endConstruct()

Flow.Launcher/Flow.Launcher.csproj:130

  • Using 'Update' for a new resource entry may not include the JSON in the build; consider using 'Include' or verify that default globbing picks it up so it’s reliably copied under the Resources folder at runtime.
    <None Update="Resources\double_pinyin.json">

@VictoriousRaptor VictoriousRaptor added this to the 2.0.0 milestone Jul 13, 2025
onesounds
onesounds previously approved these changes Jul 13, 2025
@Jack251970
Copy link
Member

LGTM

@jjw24 jjw24 dismissed their stale review July 13, 2025 14:34

Reviewed by Jack251970.

@jjw24 jjw24 removed review in progress Indicates that a review is in progress for this PR 20 min review labels Jul 13, 2025
@jjw24 jjw24 merged commit 354e5ec into dev Jul 13, 2025
6 checks passed
@jjw24 jjw24 deleted the double-pin branch July 13, 2025 14:35
@WXZhao7
Copy link

WXZhao7 commented Sep 6, 2025

This feature is really awesome, thank you for your effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Refactor enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants